Add gdk_draw_rectangle_alpha_libgtk_only which uses XRenderFillRectangle
authorAnders Carlsson <andersca@gnome.org>
Tue, 27 Jul 2004 21:58:09 +0000 (21:58 +0000)
committerAnders Carlsson <andersca@src.gnome.org>
Tue, 27 Jul 2004 21:58:09 +0000 (21:58 +0000)
2004-07-27  Anders Carlsson  <andersca@gnome.org>

* demos/gtk-demo/iconview.c: (do_iconview):
* gdk/gdkdrawable.h:
* gdk/linux-fb/gdkdrawable-fb2.c:
(gdk_draw_rectangle_alpha_libgtk_only):
* gdk/win32/gdkdrawable-win32.c:
(gdk_draw_rectangle_alpha_libgtk_only):
* gdk/x11/gdkdrawable-x11.c: (gdk_x11_draw_image),
(get_impl_drawable), (gdk_x11_draw_pixbuf),
(gdk_draw_rectangle_alpha_libgtk_only):
Add gdk_draw_rectangle_alpha_libgtk_only which uses
XRenderFillRectangle on X11. It's stubbed out on the
Win32 and fb backends.

* gtk/gtkiconview.c:
(gtk_icon_view_paint_rubberband):
Use gdk_draw_rectangle_alpha_libgtk_only here.

ChangeLog
ChangeLog.pre-2-10
ChangeLog.pre-2-6
ChangeLog.pre-2-8
demos/gtk-demo/iconview.c
gdk/gdkdrawable.h
gdk/linux-fb/gdkdrawable-fb2.c
gdk/win32/gdkdrawable-win32.c
gdk/x11/gdkdrawable-x11.c
gtk/gtkiconview.c

index b60191796f8bdf2907b6c58c26a3af3bd5652f7f..b3e1e23d60ecf104b275a3b0e09778cdc151d88c 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,22 @@
+2004-07-27  Anders Carlsson  <andersca@gnome.org>
+
+       * demos/gtk-demo/iconview.c: (do_iconview):
+       * gdk/gdkdrawable.h:
+       * gdk/linux-fb/gdkdrawable-fb2.c:
+       (gdk_draw_rectangle_alpha_libgtk_only):
+       * gdk/win32/gdkdrawable-win32.c:
+       (gdk_draw_rectangle_alpha_libgtk_only):
+       * gdk/x11/gdkdrawable-x11.c: (gdk_x11_draw_image),
+       (get_impl_drawable), (gdk_x11_draw_pixbuf),
+       (gdk_draw_rectangle_alpha_libgtk_only):
+       Add gdk_draw_rectangle_alpha_libgtk_only which uses 
+       XRenderFillRectangle on X11. It's stubbed out on the 
+       Win32 and fb backends.
+       
+       * gtk/gtkiconview.c: 
+       (gtk_icon_view_paint_rubberband):
+       Use gdk_draw_rectangle_alpha_libgtk_only here.
+
 2004-07-27  Anders Carlsson  <andersca@gnome.org>
 
        * gtk/gtkaboutdialog.c: (gtk_about_dialog_init),
index b60191796f8bdf2907b6c58c26a3af3bd5652f7f..b3e1e23d60ecf104b275a3b0e09778cdc151d88c 100644 (file)
@@ -1,3 +1,22 @@
+2004-07-27  Anders Carlsson  <andersca@gnome.org>
+
+       * demos/gtk-demo/iconview.c: (do_iconview):
+       * gdk/gdkdrawable.h:
+       * gdk/linux-fb/gdkdrawable-fb2.c:
+       (gdk_draw_rectangle_alpha_libgtk_only):
+       * gdk/win32/gdkdrawable-win32.c:
+       (gdk_draw_rectangle_alpha_libgtk_only):
+       * gdk/x11/gdkdrawable-x11.c: (gdk_x11_draw_image),
+       (get_impl_drawable), (gdk_x11_draw_pixbuf),
+       (gdk_draw_rectangle_alpha_libgtk_only):
+       Add gdk_draw_rectangle_alpha_libgtk_only which uses 
+       XRenderFillRectangle on X11. It's stubbed out on the 
+       Win32 and fb backends.
+       
+       * gtk/gtkiconview.c: 
+       (gtk_icon_view_paint_rubberband):
+       Use gdk_draw_rectangle_alpha_libgtk_only here.
+
 2004-07-27  Anders Carlsson  <andersca@gnome.org>
 
        * gtk/gtkaboutdialog.c: (gtk_about_dialog_init),
index b60191796f8bdf2907b6c58c26a3af3bd5652f7f..b3e1e23d60ecf104b275a3b0e09778cdc151d88c 100644 (file)
@@ -1,3 +1,22 @@
+2004-07-27  Anders Carlsson  <andersca@gnome.org>
+
+       * demos/gtk-demo/iconview.c: (do_iconview):
+       * gdk/gdkdrawable.h:
+       * gdk/linux-fb/gdkdrawable-fb2.c:
+       (gdk_draw_rectangle_alpha_libgtk_only):
+       * gdk/win32/gdkdrawable-win32.c:
+       (gdk_draw_rectangle_alpha_libgtk_only):
+       * gdk/x11/gdkdrawable-x11.c: (gdk_x11_draw_image),
+       (get_impl_drawable), (gdk_x11_draw_pixbuf),
+       (gdk_draw_rectangle_alpha_libgtk_only):
+       Add gdk_draw_rectangle_alpha_libgtk_only which uses 
+       XRenderFillRectangle on X11. It's stubbed out on the 
+       Win32 and fb backends.
+       
+       * gtk/gtkiconview.c: 
+       (gtk_icon_view_paint_rubberband):
+       Use gdk_draw_rectangle_alpha_libgtk_only here.
+
 2004-07-27  Anders Carlsson  <andersca@gnome.org>
 
        * gtk/gtkaboutdialog.c: (gtk_about_dialog_init),
index b60191796f8bdf2907b6c58c26a3af3bd5652f7f..b3e1e23d60ecf104b275a3b0e09778cdc151d88c 100644 (file)
@@ -1,3 +1,22 @@
+2004-07-27  Anders Carlsson  <andersca@gnome.org>
+
+       * demos/gtk-demo/iconview.c: (do_iconview):
+       * gdk/gdkdrawable.h:
+       * gdk/linux-fb/gdkdrawable-fb2.c:
+       (gdk_draw_rectangle_alpha_libgtk_only):
+       * gdk/win32/gdkdrawable-win32.c:
+       (gdk_draw_rectangle_alpha_libgtk_only):
+       * gdk/x11/gdkdrawable-x11.c: (gdk_x11_draw_image),
+       (get_impl_drawable), (gdk_x11_draw_pixbuf),
+       (gdk_draw_rectangle_alpha_libgtk_only):
+       Add gdk_draw_rectangle_alpha_libgtk_only which uses 
+       XRenderFillRectangle on X11. It's stubbed out on the 
+       Win32 and fb backends.
+       
+       * gtk/gtkiconview.c: 
+       (gtk_icon_view_paint_rubberband):
+       Use gdk_draw_rectangle_alpha_libgtk_only here.
+
 2004-07-27  Anders Carlsson  <andersca@gnome.org>
 
        * gtk/gtkaboutdialog.c: (gtk_about_dialog_init),
index 56e74da745cf7e104fcb2d56f4ce71bdfefd2edb..b9f1dc6c234d7a1996b5e5396a58bb89225408ba 100644 (file)
@@ -320,6 +320,8 @@ do_iconview (GtkWidget *do_widget)
          fill_store (store);
 
          icon_view = gtk_icon_view_new_with_model (GTK_TREE_MODEL (store));
+         gtk_icon_view_set_selection_mode (GTK_ICON_VIEW (icon_view),
+                                           GTK_SELECTION_MULTIPLE);
          g_object_unref (store);
          
          /* Connect to the "clicked" signal of the "Up" tool button */
index 89f2d43c44d72872ba6485d880de8214f61ce180..7f8058493f390e72f901659c528837b972c9774d 100644 (file)
@@ -360,6 +360,15 @@ GdkImage *gdk_drawable_copy_to_image (GdkDrawable  *drawable,
 GdkRegion *gdk_drawable_get_clip_region    (GdkDrawable *drawable);
 GdkRegion *gdk_drawable_get_visible_region (GdkDrawable *drawable);
 
+
+gboolean gdk_draw_rectangle_alpha_libgtk_only (GdkDrawable *drawable,
+                                              gint         x,
+                                              gint         y,
+                                              gint         width,
+                                              gint         height,
+                                              GdkColor    *color,
+                                              guint16      alpha);
+
 #ifdef __cplusplus
 }
 #endif /* __cplusplus */
index eca67970430bce792406adb5c159e4ad6724461b..20d11053044d71c5a0edc4fb7fbe7870c878d25a 100644 (file)
@@ -1643,3 +1643,15 @@ gdk_shadow_fb_draw_lines (GdkDrawable      *drawable,
 }
 
 #endif
+
+gboolean
+gdk_draw_rectangle_alpha_libgtk_only (GdkDrawable *drawable,
+                                     gint         x,
+                                     gint         y,
+                                     gint         width,
+                                     gint         height,
+                                     GdkColor    *color,
+                                     guint16      alpha)
+{
+  return FALSE;
+}
index c542eb9fe0ca2f3a737290f09707c3d54fe35338..286cea9284fd005362b0253cabfa5398a94b503f 100644 (file)
@@ -1822,3 +1822,15 @@ gdk_win32_drawable_get_handle (GdkDrawable *drawable)
 {
   return GDK_DRAWABLE_HANDLE (drawable);
 }
+
+gboolean
+gdk_draw_rectangle_alpha_libgtk_only (GdkDrawable *drawable,
+                                     gint         x,
+                                     gint         y,
+                                     gint         width,
+                                     gint         height,
+                                     GdkColor    *color,
+                                     guint16      alpha)
+{
+  return FALSE;
+}
index 043b3e2dcd840d0582e46b8ece5bc26c0327fcc1..7d27a48e8ab9b65d97146e8a873e6135c832bad5 100644 (file)
@@ -817,7 +817,7 @@ gdk_x11_draw_image     (GdkDrawable     *drawable,
                         gint             height)
 {
   GdkDrawableImplX11 *impl;
-  
+
   impl = GDK_DRAWABLE_IMPL_X11 (drawable);
 
 #ifdef USE_SHM  
@@ -846,7 +846,7 @@ static GdkDrawable * get_impl_drawable (GdkDrawable *drawable)
   GdkDrawable *impl;
   
   if (GDK_IS_WINDOW (drawable))
-    impl = ((GdkPixmapObject *)drawable)->impl;
+    impl = ((GdkWindowObject *)drawable)->impl;
   else if (GDK_IS_PIXMAP (drawable))
     impl = ((GdkPixmapObject *)drawable)->impl;
   else
@@ -1456,3 +1456,68 @@ gdk_x11_draw_pixbuf (GdkDrawable     *drawable,
                      rowstride,
                      dest_x, dest_y, width, height);
 }
+
+/**
+ * gdk_draw_rectangle_alpha_libgtk_only:
+ * @drawable: The #GdkDrawable to draw on
+ * @x: the x coordinate of the left edge of the rectangle.
+ * @y: the y coordinate of the top edge of the rectangle.
+ * @width: the width of the rectangle.
+ * @height: the height of the rectangle.
+ * @color: The color
+ * @alpha: The alpha value.
+ * 
+ * Tries to draw a filled alpha blended rectangle using the window
+ * system's native routines. This is not public API and must not be
+ * used by applications.
+ * 
+ * Return value: TRUE if the rectangle could be drawn, FALSE
+ * otherwise.
+ **/
+gboolean
+gdk_draw_rectangle_alpha_libgtk_only (GdkDrawable  *drawable,
+                                     gint          x,
+                                     gint          y,
+                                     gint          width,
+                                     gint          height,
+                                     GdkColor     *color,
+                                     guint16       alpha)
+{
+  Display *xdisplay;
+  XRenderColor render_color;
+  Picture pict;
+  int x_offset, y_offset;
+  GdkDrawable *real_drawable, *impl;
+
+  g_return_val_if_fail (color != NULL, FALSE);
+  
+  if (!GDK_IS_WINDOW (drawable))
+    return FALSE;
+  
+  if (!_gdk_x11_have_render (gdk_drawable_get_display (drawable)))
+    return FALSE;
+
+  gdk_window_get_internal_paint_info (GDK_WINDOW (drawable),
+                                     &real_drawable,
+                                     &x_offset, &y_offset);
+
+  impl = ((GdkWindowObject *)real_drawable)->impl;  
+      
+  pict = gdk_x11_drawable_get_picture (impl);
+
+  if (pict == None)
+    return FALSE;
+  
+  xdisplay = GDK_DISPLAY_XDISPLAY (gdk_drawable_get_display (drawable));
+
+  render_color.alpha = alpha;
+  render_color.red = color->red * render_color.alpha / 0xffff;
+  render_color.green = color->green * render_color.alpha / 0xffff;
+  render_color.blue = color->blue * render_color.alpha / 0xffff;
+
+  XRenderFillRectangle (xdisplay,
+                       PictOpOver, pict, &render_color,
+                       x - x_offset, y - y_offset,
+                       width, height);
+  return TRUE;
+}
index cf773b634556c394cfeee92159218bef174be7e5..e679642fde837e7c0d1ed8555aec3a32f8f4f847 100644 (file)
@@ -109,7 +109,7 @@ struct _GtkIconViewPrivate
   gint press_start_x;
   gint press_start_y;
 #endif
-  
+
   /* Layout used to draw icon text */
   PangoLayout *layout;
   
@@ -173,7 +173,6 @@ static gboolean gtk_icon_view_button_press   (GtkWidget      *widget,
                                              GdkEventButton *event);
 static gboolean gtk_icon_view_button_release (GtkWidget      *widget,
                                              GdkEventButton *event);
-
 /* GtkIconView signals */
 static void     gtk_icon_view_set_adjustments           (GtkIconView   *icon_view,
                                                         GtkAdjustment *hadj,
@@ -293,7 +292,7 @@ gtk_icon_view_class_init (GtkIconViewClass *klass)
   widget_class->motion_notify_event = gtk_icon_view_motion;
   widget_class->button_press_event = gtk_icon_view_button_press;
   widget_class->button_release_event = gtk_icon_view_button_release;
-  
+
   klass->set_scroll_adjustments = gtk_icon_view_set_adjustments;
   klass->select_all = gtk_icon_view_real_select_all;
   klass->unselect_all = gtk_icon_view_real_unselect_all;
@@ -736,8 +735,6 @@ gtk_icon_view_realize (GtkWidget *widget)
   widget->style = gtk_style_attach (widget->style, widget->window);
   gdk_window_set_background (icon_view->priv->bin_window, &widget->style->base[widget->state]);
   gdk_window_set_background (widget->window, &widget->style->base[widget->state]);
-
-  
 }
 
 static void
@@ -1067,7 +1064,6 @@ gtk_icon_view_button_release (GtkWidget      *widget,
   return TRUE;
 }
 
-
 static void
 gtk_icon_view_update_rubberband (gpointer data)
 {
@@ -1888,16 +1884,23 @@ gtk_icon_view_paint_rubberband (GtkIconView     *icon_view,
 
   fill_color = gtk_gdk_color_to_rgb (fill_color_gdk) << 8 | fill_color_alpha;
 
-  pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB, TRUE, 8, rect.width, rect.height);
-  gdk_pixbuf_fill (pixbuf, fill_color);
+  if (!gdk_draw_rectangle_alpha_libgtk_only (icon_view->priv->bin_window,
+                                            rect.x, rect.y, rect.width, rect.height,
+                                            fill_color_gdk,
+                                            fill_color_alpha << 8 | fill_color_alpha))
+    {
+      pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB, TRUE, 8, rect.width, rect.height);
+      gdk_pixbuf_fill (pixbuf, fill_color);
+      
+      gdk_draw_pixbuf (icon_view->priv->bin_window, NULL, pixbuf,
+                      0, 0, 
+                      rect.x,rect.y,
+                      rect.width, rect.height,
+                      GDK_RGB_DITHER_NONE,
+                      0, 0);
+      g_object_unref (pixbuf);
+    }
 
-  gdk_draw_pixbuf (icon_view->priv->bin_window, NULL, pixbuf,
-                  0, 0, 
-                  rect.x,rect.y,
-                  rect.width, rect.height,
-                  GDK_RGB_DITHER_NONE,
-                  0, 0);
-  g_object_unref (pixbuf);
   gc = gdk_gc_new (icon_view->priv->bin_window);
   gdk_gc_set_rgb_fg_color (gc, fill_color_gdk);
   gdk_gc_set_clip_rectangle (gc, &rect);